﻿namespace NetFx.SMIL.References
{
  using System;
  using System.Text;
  using System.Collections;
  using System.Collections.Generic;

  using System.Reflection;
  using System.Reflection.Emit;
  using System.Runtime.InteropServices;

  using System.Diagnostics;
  using System.Diagnostics.CodeAnalysis;
  using System.Diagnostics.SymbolStore;
  using System.Security;
  using System.Security.Permissions;

  using NetFx.MSIL;

  /// <summary>
  /// 对字段的引用。
  /// </summary>
  public class FieldRef:MemberRef
  {
    #region Statics
    public new static FieldRef it()
    {
      return new FieldRef();
    }
    public static FieldRef of(FieldInfo fieldInfo)
    {
      return new FieldRef(fieldInfo);
    }
    public static FieldRef of(string identifier)
    {
      return new FieldRef(identifier);
    }
    #endregion
    #region Properties
    /// <summary>
    /// 获取引用类型（为字段）。
    /// </summary>
    public override DefType ReflectionType
    {
      get { return DefType.Field; }
    }
    /// <summary>
    /// 获取反射信息。
    /// </summary>
    public new virtual FieldInfo ReflectInfo
    {
      get
      {
        return this.referenced as FieldInfo;
      }
    }
    public override bool HasReflectInfo
    {
      get
      {
        return this.ReflectInfo != null;
      }
    }

    #endregion
    #region Constructors
    public FieldRef() : base() { }
    public FieldRef(FieldInfo fieldInfo) : base(fieldInfo) { }
    public FieldRef(string identifier) : base(identifier, 0) { }
    protected FieldRef(string identifier, int namespacePrefixCount) : base(identifier, namespacePrefixCount) { }
    protected FieldRef(string identifier, int namespacePrefixCount, int classPrefixCount) : base(identifier, namespacePrefixCount, classPrefixCount) { }
    #endregion
    #region Methods
    protected override ReflectRef OnBinding(object source)
    {
      return base.OnBinding(source as FieldInfo);
    }

    #endregion
  }
}
